import request from '@/utils/request';
import type { AxiosPromise } from 'axios';

/**
 * 认证审核查询对象
 */
export interface UserAuthQuery extends PageQuery {
  userId?: number;
  userPhone?: string;
  realName?: string;
  authStatus?: string;
  beginTime?: string;
  endTime?: string;
}

/**
 * 认证审核对象
 */
export interface UserAuthVO {
  authId: number;
  userId: number;
  realName: string;
  docType: string; // 证件类型: idcard-身份证, passport-护照
  idCard: string; // 身份证号（脱敏）
  passportNo: string; // 护照号（脱敏）
  idCardFront: string; // 身份证人像面
  idCardBack: string; // 身份证国徽面
  passportPhoto: string; // 护照资料页照片
  faceImage: string; // 手持证件照
  authStatus: string; // 认证状态: 0-未认证, 1-审核中, 2-已认证, 3-审核失败
  auditTime: string;
  auditRemark: string;
  createTime: string;
  userPhone?: string; // 用户手机号（关联查询）
}

/**
 * 审核请求对象
 */
export interface AuditRequest {
  authId: number;
  authStatus: string;
  auditRemark?: string;
}

/**
 * 查询认证审核列表
 */
export function listUserAuth(query: UserAuthQuery): AxiosPromise<UserAuthVO[]> {
  return request({
    url: '/admin/beauty/userAuth/list',
    method: 'get',
    params: query
  });
}

/**
 * 查询认证审核详细
 */
export function getUserAuth(authId: number): AxiosPromise<UserAuthVO> {
  return request({
    url: `/admin/beauty/userAuth/${authId}`,
    method: 'get'
  });
}

/**
 * 审核认证
 */
export function auditUserAuth(data: AuditRequest) {
  return request({
    url: '/admin/beauty/userAuth/audit',
    method: 'post',
    data: data
  });
}

/**
 * 批量审核通过
 */
export function batchPassUserAuth(authIds: number[]) {
  return request({
    url: '/admin/beauty/userAuth/batchPass',
    method: 'post',
    data: authIds
  });
}

/**
 * 批量审核拒绝
 */
export function batchRejectUserAuth(authIds: number[], remark?: string) {
  return request({
    url: '/admin/beauty/userAuth/batchReject',
    method: 'post',
    data: authIds,
    params: { remark }
  });
}

/**
 * 根据用户ID查询认证信息
 */
export function getUserAuthByUserId(userId: number): AxiosPromise<UserAuthVO> {
  return request({
    url: `/admin/beauty/userAuth/user/${userId}`,
    method: 'get'
  });
}
